<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改项目')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-project-add" class="form-horizontal">
        <input type="hidden" id="id" name="id" th:value="${project.id}"/>
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">项目编号：</label>
                    <div class="col-sm-6">
                        <input name="proNumber" placeholder="请输入项目编号" class="form-control" type="text"
                               th:value="${project.proNumber}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">项目名称：</label>
                    <div class="col-sm-6">
                        <input name="proName" type="text" placeholder="请输入项目名称" class="form-control"
                               th:value="${project.proName}" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">项目类型：</label>
                    <div class="col-sm-6">
                        <select name="proType" class="form-control m-b">
                            <option value="">请选择</option>
                            <option th:each="proType : ${proType}" th:text="${proType.paramValue}"
                                    th:selected="${project.proType==proType.id}"
                                    th:value="${proType.id}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">项目状态：</label>
                    <div class="col-sm-6">
                        <select name="proStatus" class="form-control m-b">
                            <option value="">请选择</option>
                            <option th:each="proStatus : ${proStatus}" th:text="${proStatus.paramValue}"
                                    th:value="${proStatus.id}"
                                    th:selected="${project.proStatus==proStatus.id}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">开工时间：</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="startTime" placeholder="开工时间" name="startTime"
                               th:value="${project.startTime}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">竣工时间：</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="endTime" placeholder="竣工时间" name="endTime"
                               th:value="${project.endTime}">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">项目位置：</label>
                    <div class="col-sm-6">
                        <input name="proPosition" placeholder="请输入项目位置" class="form-control" type="text"
                               th:value="${project.proPosition}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">工程公司：</label>
                    <div class="col-sm-6">
                        <select name="belongComp" class="form-control m-b">
                            <option value="">请选择</option>
                            <option th:each="belongComp : ${belongComp}" th:text="${belongComp.paramValue}"
                                    th:value="${belongComp.id}"
                                    th:selected="${project.belongComp==belongComp.id}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">项目经理：</label>
                    <div class="col-sm-6">
                        <select name="proManagerPerson" class="form-control m-b">
                            <option value="">请选择</option>
                            <option th:each="person : ${person}" th:text="${person.name}"
                                    th:value="${person.id}"
                                    th:selected="${project.proManagerPerson==person.id}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">信息化负责人：</label>
                    <div class="col-sm-6">
                        <select name="proInfoPerson" class="form-control m-b">
                            <option value="">请选择</option>
                            <option th:each="person : ${person}" th:text="${person.name}"
                                    th:value="${person.id}"
                                    th:selected="${project.proInfoPerson==person.id}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">合同造价：</label>
                    <div class="col-sm-6">
                        <input name="contractCost" placeholder="请输入合同造价" class="form-control" type="text"
                               th:value="${project.contractCost}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label">项目状态：</label>
                    <div class="col-xs-6">
                        <label class="check-box">
                            <input id="network" name="network" value="1" type="checkbox" th:text="网络"
                                   th:checked="${project.network}">
                        </label>
                        <label class="check-box">
                            <input id="erp" name="erp" value="1" type="checkbox" th:text="ERP"
                                   th:checked="${project.erp}">
                        </label>
                        <label class="check-box">
                            <input id="attendance" name="attendance" value="1" type="checkbox" th:text="劳务考勤"
                                   th:checked="${project.attendance}">
                        </label>
                        <label class="check-box">
                            <input id="monitor" name="monitor" value="1" type="checkbox" th:text="监控"
                                   th:checked="${project.monitor}">
                        </label>
                        <label class="check-box">
                            <input id="devops" name="devops" value="1" type="checkbox" th:text="运维"
                                   th:checked="${project.devops}">
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script>
    var prefix = ctx + "projectManage";

    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            laydate.render({
                elem: '#startTime'
            });

            laydate.render({
                elem: '#endTime'
            });
        });
    })

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-project-add").serializeArray();
            var network = $("input[id='network']").is(':checked') == true ? 1 : 0;
            var erp = $("input[id='erp']").is(':checked') == true ? 1 : 0;
            var attendance = $("input[id='attendance']").is(':checked') == true ? 1 : 0;
            var monitor = $("input[id='monitor']").is(':checked') == true ? 1 : 0;
            var devops = $("input[id='devops']").is(':checked') == true ? 1 : 0;
            data.push({"name": "network", "value": network});
            data.push({"name": "erp", "value": erp});
            data.push({"name": "attendance", "value": attendance});
            data.push({"name": "monitor", "value": monitor});
            data.push({"name": "devops", "value": devops});
            $.operate.saveTab(prefix + "/save", data);
        }
    }

</script>
</body>
</html>